package com.audaque.springboot.foshanupload.web.webdemo.mapper;


import com.audaque.springboot.foshanupload.web.webdemo.mapper.config.CentralConfig;
import com.audaque.springboot.foshanupload.web.webdemo.mapper.covert.TypeCoverter;
import com.audaque.springboot.foshanupload.web.webdemo.model.domain.Person;
import com.audaque.springboot.foshanupload.web.webdemo.model.dto.PersonDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * 共享配置
 */

@Mapper(config = CentralConfig.class ,uses = TypeCoverter.class )
//迁移到配置接口
/**
 * 共享配置config，配置一些检查策略
 * 例如：
 * unmappedSourcePolicy()、unmappedTargetPolicy() : 源或者目标没有标注映射的属性怎么报告
 * typeConversionPolicy() :应该报告如何进行有损(缩小)转换，例如:long到integer的转换。
 * collectionMappingStrategy(): 集合类型映射策略
 */
// Effective configuration:
// @Mapper(uses = { CustomMapperViaMapper.class, CustomMapperViaMapperConfig.class },
//     unmappedTargetPolicy = ReportingPolicy.ERROR // )

public interface  SourceTargetMapper {
    SourceTargetMapper INSTANCT = Mappers.getMapper(SourceTargetMapper.class);

    @Mapping(target = "personName", ignore = true)
    @Mapping(target = "fatherName", ignore = true)
    @Mapping(target = "country", ignore = true)
    PersonDTO conver(Person person);
}
